@@ -92,6 +92,7 @@ |
||
| 92 | 92 |
<!-- build:js({.tmp,app}) scripts/scripts.js -->
|
| 93 | 93 |
<script src="scripts/app.js"></script> |
| 94 | 94 |
<script src="scripts/services/userData.js"></script> |
| 95 |
+ <script src="scripts/services/domainsData.js"></script> |
|
| 95 | 96 |
<script src="scripts/controllers/main.js"></script> |
| 96 | 97 |
<script src="scripts/controllers/domainsList.js"></script> |
| 97 | 98 |
<script src="scripts/controllers/signin.js"></script> |
@@ -21,7 +21,8 @@ angular |
||
| 21 | 21 |
'domainManagerApp.header', |
| 22 | 22 |
'domainManagerApp.main', |
| 23 | 23 |
'domainManagerApp.signin', |
| 24 |
- 'domainManagerApp.domains', |
|
| 24 |
+ 'domainManagerApp.domainsData', |
|
| 25 |
+ 'domainManagerApp.domainsList', |
|
| 25 | 26 |
'domainManagerApp.addPost' |
| 26 | 27 |
]) |
| 27 | 28 |
.config(['$routeProvider', function($routeProvider) {
|
@@ -74,10 +74,32 @@ |
||
| 74 | 74 |
|
| 75 | 75 |
// Map data from api.who.pm |
| 76 | 76 |
$scope.mapData = function(data) {
|
| 77 |
- $scope.domain.registrar = data.registrar[0]; |
|
| 78 |
- $scope.domain.registration_date = data.creation_date[0]; |
|
| 79 |
- $scope.domain.expiration_date = data.expiration_date[0]; |
|
| 80 |
- $scope.domain.owner = data.contacts.registrant.name; |
|
| 77 |
+ console.log(data); |
|
| 78 |
+ // Data: Registrar |
|
| 79 |
+ if(data.registrar != undefined){
|
|
| 80 |
+ $scope.domain.registrar = data.registrar[0]; |
|
| 81 |
+ } else {
|
|
| 82 |
+ $scope.domain.registrar = ""; |
|
| 83 |
+ } |
|
| 84 |
+ // Data: Creation Date |
|
| 85 |
+ if(data.creation_date != undefined) {
|
|
| 86 |
+ $scope.domain.registration_date = data.creation_date[0]; |
|
| 87 |
+ } else {
|
|
| 88 |
+ $scope.domain.registration_date = ""; |
|
| 89 |
+ } |
|
| 90 |
+ // Data: Expiration Date |
|
| 91 |
+ if(data.expiration_date != undefined) {
|
|
| 92 |
+ $scope.domain.expiration_date = data.expiration_date[0]; |
|
| 93 |
+ } else {
|
|
| 94 |
+ $scope.domain.expiration_date = ""; |
|
| 95 |
+ } |
|
| 96 |
+ // Data Owner |
|
| 97 |
+ if(data.contacts != undefined) {
|
|
| 98 |
+ $scope.domain.owner = data.contacts.registrant.name; |
|
| 99 |
+ } else {
|
|
| 100 |
+ $scope.domain.owner = ""; |
|
| 101 |
+ } |
|
| 102 |
+ |
|
| 81 | 103 |
} |
| 82 | 104 |
|
| 83 | 105 |
}]); |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 |
* # AboutCtrl |
| 8 | 8 |
* Controller of the domainManagerApp |
| 9 | 9 |
*/ |
| 10 |
-angular.module('domainManagerApp.domains', ['ui.bootstrap', 'firebase'])
|
|
| 11 |
- .controller('DomainsListController',['$scope', '$firebase', function ($scope, $firebase) {
|
|
| 10 |
+angular.module('domainManagerApp.domainsList', ['ui.bootstrap', 'firebase', 'domainManagerApp.domainsData'])
|
|
| 11 |
+ .controller('DomainsListController',['$scope', '$firebase', 'Domains', '$rootScope', function ($scope, $firebase, Domains, $rootScope) {
|
|
| 12 | 12 |
// $http({
|
| 13 | 13 |
// method: 'GET', |
| 14 | 14 |
// url: '/scripts/data.json' |
@@ -16,22 +16,18 @@ angular.module('domainManagerApp.domains', ['ui.bootstrap', 'firebase'])
|
||
| 16 | 16 |
// $scope.domains = data.domains; |
| 17 | 17 |
// }); |
| 18 | 18 |
|
| 19 |
- $scope.domains = []; |
|
| 19 |
+ $scope.domains = Domains.get(); |
|
| 20 | 20 |
|
| 21 |
- // Get domain list from firebase |
|
| 22 |
- var ref = new Firebase("https://j1x-cpanel.firebaseio.com/domains");
|
|
| 23 |
- ref.on("child_added", function(data) {
|
|
| 21 |
+ |
|
| 22 |
+ $rootScope.$on('domains:loaded', function(domain) {
|
|
| 24 | 23 |
if(!$scope.$$phase) {
|
| 25 | 24 |
$scope.$apply(function(){
|
| 26 |
- $scope.domains.push(data.val()); |
|
| 25 |
+ $scope.domains = Domains.get(); |
|
| 26 |
+ |
|
| 27 | 27 |
}); |
| 28 | 28 |
} |
| 29 |
- }, function (errorObject) {
|
|
| 30 |
- console.log("The read failed: " + errorObject.code);
|
|
| 31 | 29 |
}); |
| 32 | 30 |
|
| 33 |
- |
|
| 34 |
- |
|
| 35 | 31 |
$scope.oneAtATime = false; |
| 36 | 32 |
$scope.isOpen = false; |
| 37 | 33 |
|
@@ -47,3 +43,16 @@ angular.module('domainManagerApp.domains', ['ui.bootstrap', 'firebase'])
|
||
| 47 | 43 |
} |
| 48 | 44 |
|
| 49 | 45 |
}]); |
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
+ // // Get domain list from firebase |
|
| 49 |
+ // var ref = new Firebase("https://j1x-cpanel.firebaseio.com/domains");
|
|
| 50 |
+ // ref.on("child_added", function(data) {
|
|
| 51 |
+ // if(!$scope.$$phase) {
|
|
| 52 |
+ // $scope.$apply(function(){
|
|
| 53 |
+ // $scope.domains.push(data.val()); |
|
| 54 |
+ // }); |
|
| 55 |
+ // } |
|
| 56 |
+ // }, function (errorObject) {
|
|
| 57 |
+ // console.log("The read failed: " + errorObject.code);
|
|
| 58 |
+ // }); |
@@ -0,0 +1,22 @@ |
||
| 1 |
+"use strict" |
|
| 2 |
+ |
|
| 3 |
+angular.module('domainManagerApp.domainsData', ['firebase'])
|
|
| 4 |
+.service('Domains', [ '$rootScope', '$firebase', function($rootScope, $firebase) {
|
|
| 5 |
+ var domains = []; |
|
| 6 |
+ |
|
| 7 |
+ // Get domain list from firebase |
|
| 8 |
+ var ref = new Firebase("https://j1x-cpanel.firebaseio.com/domains");
|
|
| 9 |
+ ref.on("child_added", function(data) {
|
|
| 10 |
+ var domain = data.val(); |
|
| 11 |
+ domains.push(domain); |
|
| 12 |
+ console.log('loading domain: ' + domain.name);
|
|
| 13 |
+ $rootScope.$broadcast('domains:loaded', domain);
|
|
| 14 |
+ }, function (errorObject) {
|
|
| 15 |
+ console.log("The read failed: " + errorObject.code);
|
|
| 16 |
+ }); |
|
| 17 |
+ |
|
| 18 |
+ this.get = function() {
|
|
| 19 |
+ return domains; |
|
| 20 |
+ } |
|
| 21 |
+ |
|
| 22 |
+}]); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 |
<accordion close-others="oneAtATime"> |
| 2 |
- <accordion-group ng-repeat="domain in domains" is-open="isOpen"> |
|
| 2 |
+ <accordion-group ng-repeat="domain in domains track by $index" is-open="isOpen"> |
|
| 3 | 3 |
<accordion-heading ng-click="isOpen = !isOpen"> |
| 4 | 4 |
<i class="pull-left glyphicon" ng-class="{'glyphicon-chevron-down': isOpen, 'glyphicon-chevron-right': !isOpen}" style="margin-right: 10px;"></i>
|
| 5 | 5 |
{{domain.name}}
|